<?php
/**
 * Created by lzl
 * Date: 2021 2021/9/8
 * Time: 10:11
 */
namespace App\Forms;


use App\Models\File;
use App\Utils\Upload;
use Illuminate\Http\UploadedFile;

class UploadForm extends BaseForm
{

    /**
     * @param  $file
     * @return string
     * @throws \App\Exceptions\RequestException
     */
    public static function upload($file)
    {

//        if($file instanceof UploadedFile){
//            $md5_key = md5_file($file->getRealPath());
//        }else{
//            $md5_key = md5_file($file);
//        }
//
//        $fileLocal = File::where('md5_key', $md5_key)->first();
//
//        if(filled($fileLocal)){
//            return $fileLocal->url;
//        }

        $url = Upload::upload($file);

        //文件库
//        File::create(compact('url','md5_key'));
//
        return $url;
    }
}